package com.bsoft.gol.hcs.clinical.dao;


import ctd.persistence.annotation.DAOMethod;
import ctd.persistence.annotation.DAOParam;
import ctd.persistence.support.hibernate.HibernateSupportDelegateDAO;
import hcn.base.CheckAppointmentRecord;

import java.util.Date;
import java.util.List;

public abstract class CheckAppointmentRecordDAO extends HibernateSupportDelegateDAO<CheckAppointmentRecord> {
    @DAOMethod(sql = " from CheckAppointmentRecord  where status=1")
    public abstract List<CheckAppointmentRecord> queryAllCheckAppointmentRecord();

    @DAOMethod(sql = " from CheckAppointmentRecord where checkAppointmentRecordId =:id ")
    public abstract CheckAppointmentRecord getCheckAppointmentRecord(@DAOParam("id") Long id);

    @DAOMethod(sql = " from CheckAppointmentRecord where realname =:REALNAME and mobile = :MOBILE and cardtype = :CARDTYPE and IDCARD = :IDCARD and FLAG = '1' ")
    public abstract CheckAppointmentRecord getCheckAppointmentRecordByInfo(@DAOParam("REALNAME") String name, @DAOParam("MOBILE") String mobile,
                                                                           @DAOParam("CARDTYPE") String cardType, @DAOParam("IDCARD") String idCard);

    @DAOMethod(sql = " from CheckAppointmentRecord where appointmentRecordId =:appointmentRecordId " +
            "and appointmentHospitalCode = :appointmentHospitalCode order by appointment_date_time desc")
    public abstract List<CheckAppointmentRecord> queryAppointmentRecordIdAndAppointmentHospitalCode(
            @DAOParam("appointmentRecordId") String appointmentRecordId,
            @DAOParam("appointmentHospitalCode") String appointmentHospitalCode);

    @DAOMethod(sql = " from CheckAppointmentRecord where checkRequestNumber =:checkRequestNumber " +
            "and appointmentHospitalCode = :appointmentHospitalCode and status in (2,3) order by appointment_date_time desc")
    public abstract List<CheckAppointmentRecord> queryCheckRequestNumberAndAppointmentHospitalCode(
            @DAOParam("checkRequestNumber") String checkRequestNumber,
            @DAOParam("appointmentHospitalCode") String appointmentHospitalCode);

    @DAOMethod(sql = " update  CheckAppointmentRecord set status =:status , lastModifiedTime =:lastModifiedTime " +
            "where appointmentRecordId =:appointmentRecordId and appointmentHospitalCode = :appointmentHospitalCode")
    public abstract void updateAppointmentRecordIdAndAppointmentHospitalCode(
            @DAOParam("status") int status, @DAOParam("lastModifiedTime") Date lastModifiedTime,
            @DAOParam("appointmentRecordId") String appointmentRecordId,
            @DAOParam("appointmentHospitalCode") String appointmentHospitalCode);

    @DAOMethod(sql = " update  CheckAppointmentRecord set execution_sign =1  where checkRequestNumber =:checkRequestNumber ")
    public abstract void updateAppointmentRecordIdExecutionSign(@DAOParam(value = "checkRequestNumber") String checkRequestNumber);


    @DAOMethod(sql = " update  CheckAppointmentRecord set status =3 , appointment_date_time =:appointment_date_time " +
            "where check_request_number =:check_request_number ")
    public abstract void updateAppointmentRecordIdStat(
            @DAOParam("appointment_date_time") Date appointment_date_time,
            @DAOParam("check_request_number") String check_request_number);


    @DAOMethod(sql = " update  CheckAppointmentRecord set status =:status  where check_request_number =:check_request_number ")
    public abstract void updateAppointmentStats( @DAOParam("status") int status, @DAOParam("check_request_number") String check_request_number);

    @DAOMethod(sql = " from CheckAppointmentRecord where checkRequestNumber =:checkRequestNumber and status=1" +
            " order by appointment_date_time desc")
    public abstract List<CheckAppointmentRecord> queryCheckRequestNumber(
            @DAOParam("checkRequestNumber") String checkRequestNumber);


    @DAOMethod(sql = "delete from CheckAppointmentRecord where checkRequestNumber=:checkRequestNumber")
    public abstract void deleteCheckAppointmentRecordByApplicationNo(@DAOParam(value = "checkRequestNumber") String checkRequestNumber);
}
